package com.jy.adscm.operation.yx.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.jy.adscm.operation.yx.bean.Agents;
import com.jy.adscm.operation.yx.bean.QueryAgents;
import com.jy.adscm.operation.yx.mapper.mysql.AgentsMapper;
import com.jy.adscm.operation.yx.service.AgentsService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.jy.adscm.utils.AdscmBaseUtils;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zyl
 * @since 2019-07-24
 */
@Service
public class AgentsServiceImpl extends ServiceImpl<AgentsMapper, Agents> implements AgentsService {

    @Override
    public Page<Agents> selectAgents(Page<Agents> page, QueryAgents queryAgents) {
        Wrapper<Agents> wrapper =new EntityWrapper<>();
        if (AdscmBaseUtils.getInstance().isNotEmpty(queryAgents.getCompany(),null)){
            wrapper.like("company",queryAgents.getCompany());
        }
        if (AdscmBaseUtils.getInstance().isNotEmpty(queryAgents.getPersonname(),null)){
            wrapper.like("personname",queryAgents.getCompany());
        }
        if (AdscmBaseUtils.getInstance().isNotEmpty(queryAgents.getAddress(),null)){
            wrapper.like("address",queryAgents.getAddress());
        }
        if (AdscmBaseUtils.getInstance().isNotEmpty(queryAgents.getCity(),null)){
            wrapper.like("city",queryAgents.getCity());
        }
        page= super.selectPage(page,wrapper);
        page.setTotal(super.selectCount(wrapper));
         return page;
    }
}
